# Contributor: Matthias Ahouansou <matthias@ahouansou.cz>
# Maintainer: Matthias Ahouansou <matthias@ahouansou.cz>
pkgname=mautrix-slack
pkgver=0_git20230925
_gitrev=4530ff397d08d93b673cd71da4c2a75d969ca0df
pkgrel=3
pkgdesc="Matrix-Slack puppeting bridge"
url="https://go.mau.fi/mautrix-slack/"
arch="all"
license="AGPL-3.0-or-later"
makedepends="go olm-dev sqlite-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc $pkgname-doc"
source="$pkgname-$_gitrev.tar.gz::https://github.com/mautrix/slack/archive/$_gitrev.tar.gz
	mautrix-slack.initd
	mautrix-slack.confd
	default-log-dir.patch
	"
builddir="$srcdir/slack-$_gitrev"
options="net"

export GOFLAGS="$GOFLAGS -tags=libsqlite3"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	export CGO_CFLAGS="$CFLAGS"
	export CGO_LDFLAGS="$LDFLAGS"
	go build
}

check() {
	go test -v ./...
}

package() {
	install -Dm755 mautrix-slack \
		-t "$pkgdir"/usr/bin/
	install -Dm644 example-config.yaml \
		-t "$pkgdir"/etc/mautrix-slack/

	install -Dm755 "$srcdir"/mautrix-slack.initd \
		"$pkgdir"/etc/init.d/mautrix-slack
	install -Dm644 "$srcdir"/mautrix-slack.confd \
		"$pkgdir"/etc/conf.d/mautrix-slack

	install -Dm 644 LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
}

sha512sums="
d2bd2b4a52233d2ce59c7fde956ae253c97c6e28913b479fd64708759fceae8154dc71d54dadb8d515fccf6a5a43c0b77a94d0938e4c2a8333a18ac9b7965a7f  mautrix-slack-4530ff397d08d93b673cd71da4c2a75d969ca0df.tar.gz
d27fbc6c7ebe9d42eb8226e035649239e6a3e9fbdea21fd9930666da68be375df577fdf9fd6989152e3bee76c924cf77119c57056aff6def84408c4548e8c42a  mautrix-slack.initd
cda8cd828fa1e4e4c302adc79a51d9af99fb428a81639691afefad6b575f6d2ac75730ea2cc455be514fe65a9836bdeb530a86b553c34a47e4a56796ce843fe1  mautrix-slack.confd
9444fec2555b1a4a1a4db2f0d08179fdd7a9d725e0a7414cea35591dbaea642978ce2020b6889f54c40f69627b167eaa1a796abcaf216ade5a6457584c38f8dc  default-log-dir.patch
"
